<!-- BEGIN PAGE HEADER-->
<?php $this->load->view('partials/breadcrumb.tpl') ?>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<div class="row">
    <div class="col-xs-12 ">
        <!-- BEGIN SAMPLE FORM PORTLET-->
        <div class="portlet box green ">
            <?= edit_form_caption('入库') ?>

            <div class="portlet-body form">
                <?= form_open('', Array('class' => 'form-horizontal', 'role' => 'form', 'id' => 'form_edit', 'data-category-id' => $obj->id)) ?>
                <div class="form-body">
                    <?= edit_form_dropdown('shop_id', array('' => '选择账户组...') + $allShops, set_value('shop_id', $obj->shop_id), '选择账户组', "class='select2me' style='width:100%;'") ?>
                    <?= edit_form_input('batch', set_value('batch', $obj->batch), '商品批次') ?>
                    <?= edit_form_input('product_name', set_value('product_name', $obj->product_name), '商品名称') ?>
                    <?= edit_form_input('product_price', set_value('product_price', $obj->product_price), '商品单价（元）') ?>
                    <?= edit_form_input('product_quantity', set_value('product_quantity', $obj->product_quantity), '商品数量', '', 1) ?>
                    <?= edit_form_input('left_quantity', set_value('left_quantity', $obj->left_quantity), '剩余数量', '', 1) ?>
                    <?= edit_form_input('product_amount', set_value('product_amount', $obj->product_amount), '商品总价（元）') ?>
                    <?= edit_form_input('purchase_person', set_value('purchase_person', $obj->purchase_person), '采购人') ?>
                    <?= edit_form_dropdown('in_mark', array('' => '选择入库类型...') + IOSS_StaticConfig::getShippingInType(), set_value('in_mark', $obj->in_mark), '入库类型') ?>
                    <?= edit_form_dropdown('warehouse', array('' => '选择存储仓库...') + IOSS_StaticConfig::getShippingWarehouse(), set_value('warehouse', $obj->warehouse), '存储仓库', "id='storage'") ?>
                    <?= edit_form_dropdown('warehouse_area', array('' => '选择仓库存储区...') + IOSS_StaticConfig::getShippingBlock(), set_value('warehouse_area', $obj->warehouse_area), '仓库存储区', "id='area'") ?>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">采购时间</label>
                        <div class="col-xs-7">
                            <div class="input-group input-large date-picker input-daterange" data-date=""
                                 data-date-format="yyyy-mm-dd">
                                <input type="text" class="form-control" required name="purchase_time"
                                       value="<?= set_value('purchase_time', $obj->purchase_time) ?>"
                                       placeholder="采购时间">
                            </div>
                        </div>
                    </div>
                    <?= edit_form_radio_list('in_status', MShippingIn::getState(), set_value('', ($thisMethod == 'edit' ? $obj->in_status : '1')), '入库状态') ?>
                    <?= edit_form_textarea('remark', set_value('remark', $obj->remark), '备注信息') ?>
                </div>

                <div class="form-actions">
                    <div class="row">
                        <div class="col-xs-offset-3 col-xs-4">
                            <button type="button" id="add-in-submit" class="btn green">
                                <span class="md-click-circle md-click-animate"></span>保存
                            </button>
                            <a href="<?= site_url('shipping/warehouse_in/index') ?>" class="btn default">返回</a>
                        </div>
                    </div>
                </div>
                <?= form_close() ?>
            </div>
        </div>
    </div>
</div>
<link href="<?= image_url('/static/assets/global/plugins/jstree/dist/themes/default/style.min.css') ?>" rel="stylesheet"
      type="text/css"/>

<script>
    $("input[name='product_quantity']").blur(function () {
        $("input[name='left_quantity']").val(this.value);
    });

    $("#add-in-submit").click(function () {
        var p_time = $("input[name='purchase_time']").val();
        if (!p_time) {
            toastr.error('请选择采购时间！');
            return false;
        }
        $("#form_edit").submit();
    });
</script>
